package com.exception.demo02;

/**
 * @author wuJiaWei
 * @version 1.0
 * @date 2024/8/14
 * @time 15:15:51
 */
//自定义的异常类
public class MyException extends Exception{
    //传递数字 >10 抛出异常
    private int detail;
    //构造函数
    public MyException(int a){
        this.detail = a;
    }
    /**
     * 重写toString
     * 异常的打印信息
     * Returns a short description of this throwable.
     * The result is the concatenation of:
     * <ul>
     * <li> the {@linkplain Class#getName() name} of the class of this object
     * <li> ": " (a colon and a space)
     * <li> the result of invoking this object's {@link #getLocalizedMessage}
     *      method
     * </ul>
     * If {@code getLocalizedMessage} returns {@code null}, then just
     * the class name is returned.
     *
     * @return a string representation of this throwable.
     */
    @Override
    public String toString() {
        return "myException{" +detail+ '}';
    }
}
